#pragma once

#include <iostream> 
#include <String>
#using <mscorlib.dll>
#using <CSVParser.dll>
#include "SurveyAlligatorConfig.h"


namespace SurveyAlligator {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Collections::Generic;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	

     public ref class CSVGenerator
	 {
		private:
			System::String^ fileName;
			bool fileExists;
			bool DEBUG_INFO;
			System::String^ debugmsg;
			System::String^ directoryName;
			SurveyAlligatorConfig^ globalConfig;			

		protected:
			void printDebug(System::String^ s);
			bool createFile();
			
			/// <summary>
			/// Parameters: 
			///        formElement: A pointer to a html form element whose inputs we want to extract
			///                     The inputs will be extracted in the same order they appear in a HTML DOM structure of 
			///                     the form element.
			/// Returns: If the given html element is a input tag, then it depends how it returns its value.
			///          If the given element is a
			//                  text, return the value.
			///                 checkbox, collects values of all the check boxes with the same names in the inputElementList and returns them as
			///           
			/// <summary>
			///
			System::Collections::ArrayList^ extractHtmlInputTagValues(System::Windows::Forms::HtmlElement^ formElement);
			System::Collections::ArrayList^ getAllOptions(HtmlElement^ element);


		private:
			String^ unSlashFileName(String^ _fn);

		public:
			
			void appendToFile(System::Windows::Forms::HtmlElement^ formElement);
			void replaceInFile(System::Windows::Forms::HtmlElement^ formElement, System::Windows::Forms::HtmlElement^ primaryHtmlTag);
		
			/// Parameter: _fileName is the fully qualified file name
			CSVGenerator(System::String^ _fileName, SurveyAlligatorConfig^ gloablConfig); 
			~CSVGenerator() 
			{

			}


			
			System::String^ getDebugMsg();
			void clearDebugMsg();
			void startDebug();
			void endDebug();



	 }; // end of class

} // end of namespace